import 'package:flutter/material.dart';

class PageViewTest extends StatelessWidget {
  const PageViewTest({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('PageView Test'),
        ),
        body: PageView.builder(
          controller: PageController(viewportFraction: 0.8),
          onPageChanged: (value) {
            print("onPageChanged $value");
          },
          itemBuilder: (BuildContext context, int index) {
            return W1(id: index);
          },
        ));
  }
}

class W1 extends StatefulWidget {
  const W1({super.key, required this.id});

  final int id;

  @override
  State<W1> createState() => _W1State();
}

class _W1State extends State<W1> {
  @override
  Widget build(BuildContext context) {
    return Text("W1 ${widget.id}");
  }

  @override
  void initState() {
    super.initState();
    print("${widget.id} initState------------------------------------------w");
  }
}
